<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="./js/jquery-1.11.3.js"></script>
<script type="text/javascript">
	function del(id){
		$.ajax({
			url : "json/delMenu.action",
			type : "POST",
			contentType : "application/json",
			data : '{"id":"'+id+'"}',
			dataType : "json",
			success: function(data){
				var dataResult = data["dataResult"];
				var message = dataResult.message;
				alert(message);
				window.location.reload();
			},
			error: function(data){
			}
		});
	}
	function edit(id){
		  window.location.href="editmenu.html?id="+id; 
	}
	$(function(){
		$.ajax({
			url : "json/showMenu.action",
			type : "POST",
			dataType : "json",
			success: function(data){
				var dataResults = data["dataResults"];
				var menulist = dataResults.results;
				$.each(menulist,function(i,item){
					var content = "";
					var id = item["id"];
					var orderid = item["orderid"];
					var no = item["no"];
					var name = item["name"];
					var price = item["price"];
					var intro = item["intro"];
					var photo = item["photo"];
					content += "<fieldset>";
					content += "<legend>主键"+id+"</legend>";
					content += "排序：'"+orderid+"'<br>";
					content += "菜品编号：'"+no+"'<br>";
					content += "名字：'"+name+"'<br>";
					content += "价格：'"+price+"'<br>";
					content += "介绍：'"+intro+"'<br>";
					content += "图片：'"+photo+"'";
					content += "<button onclick='del("+id+")' style='width: 100px;height: 25px;'>删除</button>";
					content += "<button onclick='edit("+id+")' style='width: 100px;height: 25px;'>修改</button>";
					content += "</fieldset>";
					$("#content").append(content);
				});
				 
			},
			error: function(){
			}
		});
	});
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>